import { UserInfo } from "./user";

/** 工具 */
export type ToolInfo = {
  uid: string;
  title: string;
  logo: string;
  type: string;
  remark: string;
  href: string;
  user: UserInfo;
}



export class ToolModel {
  private _list: ToolInfo[] = [];


  public get list(): ToolInfo[] {
    return this._list;
  }

  public setList(list: ToolInfo[]): void {
    this._list = list;
  }
  public add(info: ToolInfo): void {
    this._list = (this._list || []).concat(info);
  }
  public updated(info: ToolInfo): void {
    for (let item of this._list) {
      if (item.uid === info.uid) {
        item = info;
      }
    }
  }
  public delete(uid: string): void {
    this._list = this._list.filter(val => val.uid !== uid);
  }

  public get types(): string[] {
    const types: string[] = [];
    this.list.map(val => types.push(val.type));
    return [...new Set(types)];
  }

  public get listjson() {
    return [
      {
        title: "bilibili",
        logo: "https://img2.baidu.com/it/u=838996022,3839891805&fm=253&fmt=auto&app=138&f=JPEG?w=532&h=500",
        type: '音视频类',
        remark: "众所周知，B站是一个学习网站",
        href: "https://www.bilibili.com/"
      },
      {
        title: "MyFreeMP3",
        logo: "https://npm.elemecdn.com/@liumingye/cdn2/favicon.ico",
        type: '音视频类',
        remark: "MyFreeMP3 一款在线免费听歌神器",
        href: "https://tools.liumingye.cn/music/#/"
      },
      {
        title: "base64在线加解密",
        logo: "https://img1.baidu.com/it/u=890625898,2076494244&fm=253&fmt=auto&app=120&f=PNG?w=300&h=300",
        type: '工具类',
        remark: "base64在线加解密",
        href: "/tools/base64"
      },
      {
        title: "JSON 美化",
        logo: "https://img2.baidu.com/it/u=273802390,65972146&fm=253&fmt=auto&app=138&f=JPEG?w=160&h=160",
        type: '工具类',
        remark: "JSON 美化",
        href: "/tools/json-pretty"
      },
      {
        title: "在线时间戳转换",
        logo: "https://img1.baidu.com/it/u=3599548533,1710127621&fm=253&fmt=auto&app=138&f=JPEG?w=501&h=500",
        type: '工具类',
        remark: "在线时间戳转换",
        href: "/tools/timestamp"
      },
      {
        title: "Coolors",
        logo: "https://coolors.co/assets/img/logo.svg",
        type: '前端工具',
        remark: "Get inspired by thousands of beautiful color schemes and make something cool!",
        href: "https://coolors.co/palettes/trending"
      },
      {
        title: "Animate.css",
        logo: "https://animate.style/img/animatecss-opengraph.jpg",
        type: '前端工具',
        remark: "Get inspired by thousands of beautiful color schemes and make something cool!",
        href: "https://animate.style/"
      },
      {
        title: "TDesign",
        logo: "https://picx.zhimg.com/v2-8ee16fc33e15e4b187007998558c2631_l.jpg?source=172ae18b",
        type: '前端UI组件库',
        remark: "TDesign 是腾讯各业务团队在服务业务过程中沉淀的一套企业级设计体系",
        href: "https://tdesign.tencent.com"
      },
    ]
  }
}